home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / w3 / w3-speak.el.z / w3-speak.el
Encoding:
Text File  |  1998-05-21  |  6.4 KB  |  179 lines

  1. ;;; w3-speak.el,v --- Emacs-W3 speech interface
  2. ;; Author: wmperry
  3. ;; Original author: William Perry --<wmperry@cs.indiana.edu>
  4. ;; Cloned from emacspeak-w3.el
  5. ;; Created: 1996/10/16 20:56:40
  6. ;; Version: 1.14
  7. ;; Keywords: hypermedia, speech
  8.  
  9. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  10. ;;; Copyright (c) 1996 by T.V. Raman (raman@adobe.com)
  11. ;;; Copyright (c) 1996, 1997 by William M. Perry (wmperry@spry.com)
  12. ;;; Copyright (c) 1997 Free Software Foundation, Inc.
  13. ;;;
  14. ;;; This file is not part of GNU Emacs, but the same permissions apply.
  15. ;;;
  16. ;;; GNU Emacs is free software; you can redistribute it and/or modify
  17. ;;; it under the terms of the GNU General Public License as published by
  18. ;;; the Free Software Foundation; either version 2, or (at your option)
  19. ;;; any later version.
  20. ;;;
  21. ;;; GNU Emacs is distributed in the hope that it will be useful,
  22. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24. ;;; GNU General Public License for more details.
  25. ;;;
  26. ;;; You should have received a copy of the GNU General Public License
  27. ;;; along with GNU Emacs; see the file COPYING.  If not, write to the
  28. ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  29. ;;; Boston, MA 02111-1307, USA.
  30. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  31.  
  32. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  33. ;;; A replacement module for emacspeak-w3 that uses all the new functionality
  34. ;;; of Emacs-W3 3.0.
  35. ;;;
  36. ;;; This file would not be possible without the help of
  37. ;;; T.V. Raman (raman@adobe.com) and his continued efforts to make Emacs-W3
  38. ;;; even remotely useful. :)
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  40.  
  41. ;;; This conforms to http://www4.inria.fr/speech2.html
  42.  
  43. (require 'widget)
  44. (require 'w3-forms)
  45. (require 'advice)
  46. ;; This condition-case needs to be here or it completely chokes
  47. ;; byte-compilation for people who do not have Emacspeak installed.
  48. ;; *sigh*
  49. (condition-case ()
  50.     (progn
  51.       (require 'emacspeak)
  52.       (require 'dtk-voices)
  53.       (require 'emacspeak-speak)
  54.       (require 'emacspeak-sounds)
  55.       (eval-when (compile)
  56.          (require 'emacspeak-fix-interactive)))
  57.   (error (message "Emacspeak not found - speech will not work.")))
  58.  
  59.  
  60. ;;{{{  speaking form fields 
  61.  
  62. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  63. ;;; Now for the guts
  64. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  65. (defun w3-speak-summarize-form-field ()
  66.   "Summarizes field under point if any."
  67.   (let ((widget (widget-at (point))))
  68.     (and widget (w3-form-summarize-field widget))))
  69.  
  70. ;;}}}
  71.  
  72. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  73. ;;; Movement notification
  74. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  75. (defadvice w3-widget-forward (after emacspeak pre act comp)
  76.   (when (interactive-p)
  77.     (emacspeak-auditory-icon 'large-movement)
  78.     (emacspeak-widget-summarize (widget-at  (point )))))
  79.  
  80. (defadvice w3-widget-backward (after emacspeak pre act comp)
  81.   (when (interactive-p)
  82.     (emacspeak-auditory-icon 'large-movement)
  83.     (emacspeak-widget-summarize (widget-at  (point )))))
  84.  
  85. (defadvice w3-scroll-up (after emacspeak pre act comp)
  86.   "Provide auditory feedback"
  87.   (when (interactive-p)
  88.     (let ((start (point )))
  89.       (emacspeak-auditory-icon 'scroll)
  90.       (save-excursion
  91.         (forward-line (window-height))
  92.         (emacspeak-speak-region start (point ))))))
  93.  
  94. (defadvice w3-revert-form (after emacspeak pre act)
  95.   "Announce that you cleared the form. "
  96.   (dtk-speak "Cleared the form. "))
  97.  
  98. (defadvice w3-finish-text-entry (after emacspeak pre act )
  99.   "Announce what the field was set to."
  100.   (when (interactive-p)
  101.     (w3-speak-summarize-form-field)))
  102.  
  103. (defadvice w3-start-of-document (after emacspeak pre act)
  104.   "Produce an auditory icon.  Also speak the first line. "
  105.   (when (interactive-p)
  106.     (emacspeak-speak-line)
  107.     (emacspeak-auditory-icon 'large-movement)))
  108.  
  109. (defadvice w3-end-of-document (after emacspeak pre act)
  110.   "Produce an auditory icon.  Also speak the first line."
  111.   (when (interactive-p)
  112.     (emacspeak-speak-line)
  113.     (emacspeak-auditory-icon 'large-movement)))
  114.  
  115. (defadvice w3-goto-last-buffer (after emacspeak pre act)
  116.   "Speak the modeline so I know where I am."
  117.   (when (interactive-p)
  118.     (emacspeak-auditory-icon 'select-object)
  119.     (emacspeak-speak-mode-line)))
  120.  
  121. (defadvice w3-quit (after emacspeak pre act)
  122.   "Speak the mode line of the new buffer."
  123.   (when (interactive-p)
  124.     (emacspeak-auditory-icon 'close-object)
  125.     (emacspeak-speak-mode-line)))
  126.  
  127. (defadvice w3-fetch (around  emacspeak  act comp )
  128.   "First produce an auditory icon to indicate retrieval.
  129. After retrieval, 
  130. set  voice-lock-mode to t after displaying the buffer,
  131. and then speak the mode-line. "
  132.   (declare (special dtk-punctuation-mode))
  133.   (emacspeak-auditory-icon 'select-object)
  134.   ad-do-it)
  135.  
  136. (defun w3-speak-mode-hook ()
  137.   (set (make-local-variable 'voice-lock-mode) t)
  138.   (setq dtk-punctuation-mode "some")
  139.   (emacspeak-auditory-icon 'open-object)
  140.   (emacspeak-speak-mode-line))
  141.  
  142. ;;; This is really the only function you should need to call unless
  143. ;;; you are adding functionality.
  144. (defun w3-speak-use-voice-locking (&optional arg) 
  145.   "Tells w3 to start using voice locking.
  146. This is done by setting the w3 variables so that anchors etc are not marked by
  147. delimiters. We then turn on voice-lock-mode. 
  148. Interactive prefix arg does the opposite. "
  149.   (interactive "P")
  150.   (declare (special w3-echo-link))
  151.   (setq w3-echo-link 'text)
  152.   (if arg
  153.       (remove-hook 'w3-mode-hook 'w3-speak-mode-hook)
  154.     (add-hook 'w3-mode-hook 'w3-speak-mode-hook)))
  155.  
  156. (defun w3-speak-browse-page ()
  157.   "Browse a WWW page"
  158.   (interactive)
  159.   (emacspeak-audio-annotate-paragraphs)
  160.   (emacspeak-execute-repeatedly 'forward-paragraph))
  161.  
  162. (declaim (special w3-mode-map))
  163. (define-key w3-mode-map "." 'w3-speak-browse-page)
  164.  
  165. (defvar url-speak-last-progress-indication 0
  166.   "Caches when we last produced a progress auditory icon")
  167.  
  168. (defadvice url-lazy-message (around emacspeak pre act)
  169.   "Provide pleasant auditory feedback about progress"
  170.   (declare (special url-speak-last-progress-indication ))
  171.   (let ((now (nth 1 (current-time))))
  172.     (when (> now
  173.          (+ 3 url-speak-last-progress-indication))
  174.       (setq url-speak-last-progress-indication now)
  175.       (apply 'message (ad-get-args 0))
  176.       (emacspeak-auditory-icon 'progress))))
  177.  
  178. (provide 'w3-speak)
  179.